package com.xinxin.intelligenceexam.presenter;

import android.text.TextUtils;

import com.xinxin.intelligenceexam.activity.SplashActivity;
import com.xinxin.intelligenceexam.base.BaseView;
import com.xinxin.intelligenceexam.base.Constant;
import com.xinxin.intelligenceexam.contract.SplashContract;
import com.xinxin.intelligenceexam.model.SplashModelImpl;
import com.xinxin.intelligenceexam.utils.SharedPreferencesUtil;

/**
 * Created by x9259 on 2016/11/09
 */

public class SplashPresenterImpl implements SplashContract.Presenter {
    SplashContract.Model mModel;
    private SplashContract.View mView;

    public SplashPresenterImpl() {
        mModel = new SplashModelImpl();
    }

    @Override
    public void checkLogin() {
        if (!TextUtils.isEmpty(SharedPreferencesUtil.getString(((SplashActivity) mView), Constant.SHAREPREFENCE, Constant.SP_STUDENT))) {
            mView.gotoMain();
        } else {
            mView.gotoLogin();
        }
    }

    @Override
    public void attachView(BaseView view) {
        mView = (SplashContract.View) view;
        if (Constant.DEBUG && Constant.DEBUG_STUDY) {
            mView.gotoStudyMenu();
        }else {
            checkLogin();
        }
    }
}